<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="icon" th:href="@{/img/logo.ico}" href="../static/img/logo.ico" type="images/x-ico"/>

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="../static/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}">
    <title>成绩查询</title>
    <link rel="stylesheet" th:href="@{/fontawesome/css/font-awesome.min.css}"
          href="../../static/fontawesome/css/font-awesome.min.css">

    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,500;0,600;0,700;1,400&display=swap">

    <!-- Fontawesome CSS -->
    <link rel="stylesheet" href="../static/fontawesome/css/fontawesome.min.css"
          th:href="@{/fontawesome/css/fontawesome.min.css}">
    <link rel="stylesheet" href="../static/fontawesome/css/all.min.css" th:href="@{/fontawesome/css/all.min.css}">

    <!-- Main CSS -->
    <link rel="stylesheet" href="../static/css/back_index.css" th:href="@{/css/back_index.css}">
    <style type="text/css">
        table {
            table-layout: fixed;
        }

        td {
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
    </style>
</head>
<body>
<div class="main-wrapper">
    <div th:replace="commons/bar::#studentmenubar(activeUri1='成绩查询')"></div>
    <div class="page-wrapper">
        <div class="content container-fluid">
            <span><small><span style="color: red">注</span>：只展示已出成绩的学科。如有任何问题可与任课老师联系。</small></span>
            <table class="table table-bordered table-striped table-hover" id="datas">
                <thead>
                <th>名称</th>
                <th>学时</th>
                <th>学分</th>
                <th>平时成绩</th>
                <th>期末成绩</th>
                <th>总成绩</th>
                </thead>
                <tbody>
                <tr id="template">
                    <td class="courseId"></td>
                    <td class="time"></td>
                    <td class="credits"></td>
                    <td class="score1"></td>
                    <td class="score2"></td>
                    <td class="sum"></td>
                    </td>
                </tr>
                </tbody>
            </table>
            <footer>
                <p>2020 &copy; 软件学院学生信息管理系统 by 郑焙元</p>
            </footer>
        </div>
    </div>
</div>
<script src="../static/js/jquery-3.5.1.min.js" th:src="@{/js/jquery-3.5.1.min.js}"></script>
<script>
    $(function () {
        sendAjax("/student/api/course", "get", {}, function (res) {
            $.each(res.data, function (i, course) {
                var row = $("#template").clone();
                sendAjax("/student/api/score/" + course.courseid, "get", {}, function (res) {
                    row.find(".courseId").text(course.courseid);
                    row.find(".time").text(course.time);
                    row.find(".credits").text(course.credits);
                    row.find(".score1").text(new Number(res.data.score1).toFixed(2));
                    row.find(".score2").text(new Number(res.data.score2).toFixed(2));
                    row.find(".sum").text(new Number(Number(res.data.score1) + Number(res.data.score2)).toFixed(2));
                    if (res.data.score1 === 0 && res.data.score2 === 0) {
                        row.remove();
                    }
                }, "");
                row.appendTo("#datas");
            });
            $("#template:first").remove();
        }, "")
    });
</script>
<script src="../static/js/popper.min.js" th:src="@{/js/popper.min.js}"></script>
<script src="../static/js/bootstrap.min.js" th:src="@{/js/bootstrap.min.js}"></script>
<script src="../static/js/jquery.slimscroll.min.js" th:src="@{/js/jquery.slimscroll.min.js}"></script>
<script src="../static/js/script.js" th:src="@{/js/script.js}"></script>

</body>
</html>
